package config

import "flow-calc/common"

/**
 *    Description: flow流相关的配置
 *    Date: 2024/3/15
 */

/* 文件配置:
kisType: flow
status: 1
flowName: MyFlow1
flows:
  - fName: 测试PrintInput
    params:
      args1: value1
      args2: value2
  - fName: 测试KisFunction_S1
  - fName: 测试PrintInput
    params:
      args1: value11
      args2: value22
      default2: newDefault
  - fName: 测试PrintInput
  - fName: 测试KisFunction_S1
    params:
      user_id: 200
  - fName: 测试PrintInput
*/

type (
	FlowFunctionParam struct {
		FName  string `yaml:"fName"`
		Params FParam `yaml:"params"`
	}
)

type FlowConfig struct {
	KisType  string              `yaml:"kisType"`
	Status   int                 `yaml:"status"`
	FlowName string              `yaml:"flowName"`
	Flows    []FlowFunctionParam `yaml:"flows"`
}

func NewFlowConfig(flowName string, enable common.OnOff) *FlowConfig {
	config := new(FlowConfig)
	config.KisType = common.FlowType
	config.FlowName = flowName
	config.Status = int(enable)
	config.Flows = make([]FlowFunctionParam, 0)
	return config
}

func (flowConfig *FlowConfig) AppendFunctionConfig(funcParam FlowFunctionParam) {
	flowConfig.Flows = append(flowConfig.Flows, funcParam)
}
